home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr10
/
v12n12.zip
/
PCMCVT.ZIP
/
PCMASM.ZIP
/
W4WCONV.INC
< prev
next >
Wrap
Text File
|
1993-05-22
|
5KB
|
179 lines
;W4WCONV.INC
;Copyright (c) 1993 Jay Munro
;First Published in PC Magazine June 29 1993
;Conversion module for WinWord 1.x & 2.0
;
;Each module is responsible for reading and writing text via the system
;buffers. Command line flags are global and available.
Word4WINCVT Proc Near
Lea SI, HeaderBuffer ;get address of header to check
Invoke Seek, SHandle, [SI].MSW4wfcMin ;seek to start of file
Jnc @F
Jmp W4WExit ;error, bag out
@@:
Mov Word Ptr AX, [SI+1Ch] ;get low word of end of text
Mov MSW4WFileEnd,AX
Mov Word Ptr AX,[SI+1Eh] ;and high byte
Mov MSW4WFileEnd[2],AX
Mov AX, [SI].MSW4wfcMin ;get the offset of beginning of file
Mov DX, [SI].MSW4wfcMin[2] ; DWord
Sub Word Ptr MSW4WFileEnd,AX ;subtract starting point to get
Sbb Word Ptr MSW4WFileEnd[2],DX ; actual text of the file
ReadW4WFile:
Call W4WReadIt ;go read the file
RW4WLoop: ;weed out control chars
LodSb ;load a character
Sub Word Ptr MSW4WFileEnd, 1
Sbb Word Ptr MSW4WFileEnd[2], 0
Cmp Word Ptr MSW4WFileEnd, 0
Jnz @F
Cmp Word Ptr MSW4WFileEnd[2], 0
Jnz @F
Call FlushIt
Jmp W4WExit ;exit stage left
MSW4WFileEnd DW 0,0 ;text length tracker
FieldCounter DB 0,0 ;counter for nested fields
@@:
Cmp AL,13 ;a carriage return?
Jnz @F
Jmp WriteWhatsLeft
@@:
Cmp AL,10 ;hard cr for W4W
Jnz @F
Jmp WriteWhatsLeft
@@:
Cmp AL,11
Jnz @F
Mov AL,13
Call WriteIt ;write what's in AL
Mov AL,10 ;make it a hard return
Jmp WriteWhatsLeft
@@:
Cmp AL,'Æ'
Jnz @F
Mov AL,39 ;apostrophe
Jmp WriteWhatsLeft
@@:
Cmp AL,15 ;em dash?
Jnz @F ;nope, keep going
Mov AL,'ù' ;fake it
@@:
Cmp AL,'ù'
Jnz @F
Mov AL,'-' ;store dual hyphans
Call W4WWrite
Mov AL,'-' ;store dual hyphans
Jmp WriteWhatsLeft
@@:
Cmp AL,147 ; Quotes
Jl @F ;nope
Cmp AL,148
Jg @F
Mov AL,34 ;substitute quotes
Jmp WriteWhatsLeft
@@:
Cmp AL,2 ;print current date;
Jnz @F ;future expansion
Jmp W4WReLoop
@@:
Cmp AL,3 ;print current time
Jnz @F ;future expansion
Jmp W4WReLoop
@@:
Cmp AL,7 ;columns
Jnz @F
Jmp W4WReLoop
@@:
Cmp AL,9 ;tab
Jnz @F
Call DoTabs ;expand the tabs
Jmp W4WReLoop
@@:
Cmp AL,19 ;start of field
Jnz W4WSkipRest
Mov FieldCounter,0
CountField:
Inc Byte Ptr Fieldcounter ;keep a count of the number of fields
Dec CX
Jz FieldReRead
FieldLoop:
Sub Word Ptr MSW4WFileEnd, 1 ;decrement file tracking variable
Sbb Word Ptr MSW4WFileEnd[2], 0
LodSb
Cmp AL,21
Jz @F ;end of loop
Cmp AL,19
Jz CountField ;if nested then count it
Loop FieldLoop
Jmp FieldReRead
@@:
Dec Byte Ptr FieldCounter ;keep track of nested fields
Jz W4WSkipRest
Loop FieldLoop
FieldReRead:
Call W4WReadIt ;ran out of characters, go for more
Jc W4WExit
Jmp FieldLoop
RW4WLoopLily:
Jmp RW4WLoop
W4WSkipRest:
Cmp AL,31 ;ok, skip the rest
Jbe W4WReLoop ;skip it
Cmp AL,196 ;two other skippers
Jz W4WReLoop
Cmp AL,254 ;columns etc...
Jae W4WReLoop
WriteWhatsLeft:
Call W4WWrite ;call our local write module
Jmp W4WReLoop
W4WReLoop:
Loop RW4WLoopLily
Jmp ReadW4WFile ;go back for more
W4WWrite:
Call WriteIt ;no, then write it
Jc BadW4WExit
RetN
W4WReadIt:
Call ReadIt ;go read the file
Jnc @F ;a fine read, continue
Mov AL,-1 ;a bad read, quit now
Call W4WWrite ;flush buffer
Jmp BadW4WExit
@@:
RetN
BadW4WExit:
Pop DX ;clean up stack
W4WExit:
Ret
Word4WINCVT EndP